﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine.utils.console;

namespace Imaginarium.team
{
    public class DamageMaker
    {
        public Character Target { get; set; }
        public bool isMagic { get; set; }
        public int normalDamage { get; set; }
        public int fireDamage { get; set; }
        public int waterDamage { get; set; }
        public int earthDamage { get; set; }
        public int windDamage { get; set; }
        public bool missed { get; set; }

        public void doDamage() {
            this.normalize();
            ImaginariumConsole.getInstance().write(this.Target.name + " recived:\n");
            doNormalDamage();
            doFireDamage();
            doWaterDamage();
            doWindDamage();
            doEarthDamage();
        }
        private void doNormalDamage() {
            if(!isMagic)
                ImaginariumConsole.getInstance().write(normalDamage.ToString(), ConsoleColor.Black, ConsoleColor.White);
            else
                ImaginariumConsole.getInstance().write(normalDamage.ToString(), ConsoleColor.Gray, ConsoleColor.White);
            Target.sustractHp(normalDamage);
        }
        private void doFireDamage()
        {
            ImaginariumConsole.getInstance().write(fireDamage.ToString(), ConsoleColor.Red, ConsoleColor.White);
            Target.sustractHp(fireDamage);
        }
        private void doWaterDamage()
        {
            ImaginariumConsole.getInstance().write(waterDamage.ToString(), ConsoleColor.Magenta, ConsoleColor.White);
            Target.sustractHp(waterDamage);
        }
        private void doWindDamage()
        {
            ImaginariumConsole.getInstance().write(windDamage.ToString(), ConsoleColor.Blue, ConsoleColor.White);
            Target.sustractHp(windDamage);
        }
        private void doEarthDamage()
        {
            ImaginariumConsole.getInstance().write(earthDamage.ToString(), ConsoleColor.Green, ConsoleColor.White);
            Target.sustractHp(earthDamage);
        }
        private void normalize() {
            if (this.earthDamage < 0) earthDamage = 0;
            if (this.waterDamage < 0) waterDamage = 0;
            if (this.windDamage < 0) windDamage = 0;
            if (this.fireDamage < 0) fireDamage = 0;
        }
        public int getTotalDamage() 
        {
            return normalDamage + earthDamage + waterDamage + windDamage + fireDamage;
        }
    }
}
